package com.smforj.ssm.modules.eslib.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.smforj.ssm.frame.core.dao.impl.BaseDaoSupport;
import com.smforj.ssm.frame.core.utils.BeanUtils;
import com.smforj.ssm.modules.eslib.dao.CirculationDao;
import com.smforj.ssm.modules.eslib.domain.Circulation;

@Repository 
public class CirculationDaoImpl extends BaseDaoSupport<Circulation> implements CirculationDao { 

	@Override
	public Circulation getCirculationByRfid(String rfid) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("rfid", rfid); 
		return getSqlSessionTemplate().selectOne(getSqlName("getCirculationByRfid"), params);
	}

	@Override
	public Circulation getCirculationBytsm(String tsm) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("tsm", tsm); 
		return getSqlSessionTemplate().selectOne(getSqlName("getCirculationBytsm"), params);
	}

	@Override
	public Circulation getCirculation(String tsm, String jsrbh) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("tsm", tsm); 
		params.put("jsrbh", jsrbh); 
		return getSqlSessionTemplate().selectOne(getSqlName("getCirculation"), params);
	}

	@Override
	public List<Circulation> getCirculations(String jsrbh) {
		Map<String, Object> params = new HashMap<String, Object>(); 
		params.put("jsrbh", jsrbh); 
		return getSqlSessionTemplate().selectList(getSqlName("getCirculations"), params);
	}

	@Override
	public int insertCirculation(Circulation cir) { 
		Map<String, Object> params = BeanUtils.toMap(cir);
		return getSqlSessionTemplate().insert(getSqlName("insertCirculation"), params);
	}

	@Override
	public int deleteCirculation(Circulation cir) {
		Map<String, Object> params = BeanUtils.toMap(cir);
		return getSqlSessionTemplate().insert(getSqlName("deleteCirculation"), params);
	}

	@Override
	public int updateCirculation(Circulation cir) {
		Map<String, Object> params = BeanUtils.toMap(cir);
		return getSqlSessionTemplate().insert(getSqlName("updateCirculation"), params);
	}
 

}
